import { createApp } from 'vue'
import App from './App.vue'
import socketService from './utils/socketService'
import eventBus from 'vue3-eventbus'

const app = createApp(App)
app.use(eventBus)
app.config.devtools = true

// 动态导入并注册拖拽缩放指令
async function registerDirectives() {
    try {
        const { default: draggableResizable } = await import(`${import.meta.env.VITE_API_BASE_URL}/directives/draggableResizable/index.js`)
        app.directive('draggable-resizable', draggableResizable)
    } catch (error) {
        console.error('指令加载失败:', error)
    }
}

// 注册指令并启动应用
registerDirectives().then(() => {
    // 初始化 WebSocket 连接
    socketService.initWebSocket(socketService.WS_URL)  
    app.mount('#app')
})
